<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">
    <ui:composition template="layout.xhtml">
        <ui:define name="body">
            <h3 class="title">Visualizar Cadastro Domiciliar</h3>

            <h:form id="form" enctype="multipart/form-data">

                <p:growl id="messages" showDetail="false" autoUpdate="true" />
                <hr/>

                <p:panel id="cabecalhoPanel" styleClass="container_24 clearfix withoutBorder">
                    <h5 class="title">Cabeçalho</h5>

                    <p:outputLabel value="Nº do cartão SUS do profissional:" styleClass="grid_8" for="susProfissional"/>
                    <p:inputText id="susProfissional" styleClass="grid_6" readonly="true"
                                 value="#{managerEditarCadastroDomiciliar.cadastro.profissional.numeroCartaoSus}"/>
                    <div class="clear-both"/>

                    <p:outputLabel value="Nome:" styleClass="grid_8" for="nomeProfissional" />
                    <p:inputText id="nomeProfissional" styleClass="grid_15" readonly="true"
                                 value="#{managerEditarCadastroDomiciliar.cadastro.profissional.nome}" />
                    <div class="clear-both"/>

                    <p:outputLabel value="Cod. CNES unidade:" styleClass="grid_8" for="cnes" />
                    <p:inputText id="cnes" styleClass="grid_6" readonly="true"
                                 value="#{managerEditarCadastroDomiciliar.cadastro.profissional.equipe.unidade.codigoCNES}" />

                    <p:outputLabel value="Microárea:" styleClass="grid_4 alpha" for="microarea" />
                    <p:inputText id="microarea" styleClass="grid_5" readonly="true"
                                 value="#{managerEditarCadastroDomiciliar.cadastro.profissional.microArea.nome}" />
                    <div class="clear-both"/>

                    <p:outputLabel value="Cod. equipe (INE):" styleClass="grid_8" for="equipeIne" />
                    <p:inputText id="equipeIne" styleClass="grid_6" readonly="true"
                                 value="#{managerEditarCadastroDomiciliar.cadastro.profissional.equipe.codigo}" />

                    <p:outputLabel value="Data do cadastro:" styleClass="grid_4 alpha" for="dataCadastro" />
                    <p:inputText id="dataCadastro" styleClass="grid_5" readonly="true"
                                 value="#{managerEditarCadastroDomiciliar.cadastro.dataCadastro}">
                        <f:convertDateTime pattern="dd/MM/yyyy"/>
                    </p:inputText>
                    <div class="clear-both"/>

                </p:panel>

                <p:panel id="enderecoPanel" styleClass="container_24 clearfix withoutBorder">
                    <h5 class="title">Endereço</h5>

                    <p:outputLabel value="CEP:" styleClass="grid_3" for="cepInputMask" />
                    <p:inputMask id="cepInputMask" styleClass="grid_4" mask="99.999-999" 
                                 autocomplete="false" readonly="true"
                                 value="#{managerEditarCadastroDomiciliar.cadastro.endereco.cep}"/>

                    <p:outputLabel value="Tipo Logradouro:" styleClass="grid_5 alpha" for="tipoLogradouro"/>
                    <p:inputText id="tipoLogradouro" styleClass="grid_10" readonly="true"
                                 value="#{managerEditarCadastroDomiciliar.cadastro.endereco.tipoLogradouro.nome}"/>

                    <div class="clear"/>
                    <p:outputLabel value="Logradouro:" styleClass="grid_3 logradouroLabelImovel" for="logradouroInputText"/>
                    <p:inputText id="logradouroInputText" styleClass="grid_19" readonly="true"
                                 value="#{managerEditarCadastroDomiciliar.cadastro.endereco.logradouro}" />
                    <div class="clear"/>

                    <p:outputLabel value="Bairro:" styleClass="grid_3" for="bairroInputText"/>
                    <p:inputText id="bairroInputText" styleClass="grid_19" readonly="true"
                                 value="#{managerEditarCadastroDomiciliar.cadastro.endereco.bairro.nome}" />

                    <p:outputLabel value="Número:" styleClass="grid_3" for="numInputText" />
                    <p:inputText id="numInputText" styleClass="grid_4" readonly="true"
                                 value="#{managerEditarCadastroDomiciliar.cadastro.endereco.numero}"/>

                    <p:outputLabel value="Complemento:" styleClass="grid_5 alpha" for="compInputText" />
                    <p:inputText id="compInputText" styleClass="grid_10" readonly="true"
                                 value="#{managerEditarCadastroDomiciliar.cadastro.endereco.complemento}"/>
                </p:panel>

                <p:panel id="telefonesPanel" styleClass="container_24 clearfix withoutBorder">
                    <h5 class="title">Telefones para contato</h5>

                    <p:outputLabel value="Residencial:" styleClass="grid_3" for="residencialInputText" />
                    <p:inputMask id="residencialInputText" styleClass="grid_7"
                                 mask="(99) 9999-9999" readonly="true"
                                 value="#{managerEditarCadastroDomiciliar.cadastro.telefoneResidencial}"/>

                    <p:outputLabel value="Referência:" styleClass="grid_4" for="referenciaInputText" />
                    <p:inputMask id="referenciaInputText" styleClass="grid_7"
                                 mask="(99) 9999-9999" readonly="true"
                                 value="#{managerEditarCadastroDomiciliar.cadastro.telefoneReferencia}"/>

                </p:panel>

                <p:panel id="moradiaPanel" styleClass="container_24 clearfix withoutBorder">
                    <h5 class="title">Condições de moradia</h5>

                    <fieldset class="grid_11">
                        <legend>Situação de moradia / posse da terra</legend>

                        <p:inputText id="situacaoMoradia" styleClass="grid_23" readonly="true"
                                     value="#{managerEditarCadastroDomiciliar.cadastro.situacaoMoradia.nome}"/>
                    </fieldset>

                    <fieldset class="grid_11">
                        <legend>Localização</legend>

                        <p:inputText id="localizacaoMoradia" styleClass="grid_23" readonly="true"
                                     value="#{managerEditarCadastroDomiciliar.cadastro.localizacaoMoradia.nome}"/>
                    </fieldset>
                    <div class="clear-both"/>

                    <p:panel id="areaRuralPanel" style="margin: 0; padding: 0" styleClass="container_24 clearfix withoutBorder">
                        <fieldset style="#{managerEditarCadastroDomiciliar.cadastro.localizacaoMoradia eq 'RURAL' ? '' : 'display: none'}">
                            <legend>Em caso de área rural: Condição de posse e uso da terra</legend>

                            <p:inputText readonly="true" value="#{managerEditarCadastroDomiciliar.cadastro.condicaoPosseMoradia.nome}"/>

                        </fieldset>
                    </p:panel>

                    <fieldset class="grid_23">
                        <legend>Tipo domicílio</legend>

                        <p:inputText readonly="true" styleClass="grid_11" value="#{managerEditarCadastroDomiciliar.cadastro.tipoDomicilio.nome}"/>
                        <div class="clear-both"/>

                        <fieldset class="grid_11 omega">
                            <legend>Nº de moradores</legend>

                            <p:inputText id="numeroMoradores" styleClass="grid_24 alpha" readonly="true"
                                         value="#{managerEditarCadastroDomiciliar.cadastro.numeroMoradores}"/>
                        </fieldset>

                        <fieldset class="grid_12 omega">
                            <legend>Nº de cômodos</legend>

                            <p:inputText id="numeroComodos" styleClass="grid_24 alpha" readonly="true"
                                         value="#{managerEditarCadastroDomiciliar.cadastro.numeroComodos}"/>
                        </fieldset>
                    </fieldset>

                    <fieldset class="grid_11">
                        <legend>Tipo de acesso ao domicílio</legend>

                        <p:inputText readonly="true" styleClass="grid_23" value="#{managerEditarCadastroDomiciliar.cadastro.tipoAcessoDomicilio.nome}"/>
                        <div class="clear-both"/>
                    </fieldset>

                    <fieldset class="grid_11">
                        <legend>Disponibilidade de energia elétrica</legend>

                        <p:inputText readonly="true" styleClass="grid_23" value="#{managerEditarCadastroDomiciliar.cadastro.disponibilidadeEnergiaEletrica ? 'Sim' : 'Não'}"/>
                    </fieldset>
                    <div class="clear-both"/>

                    <fieldset class="grid_23">
                        <legend>Material predominante na construção das paredes externas de seu domicílio</legend>

                        <p:inputText readonly="true" styleClass="grid_23" value="#{managerEditarCadastroDomiciliar.cadastro.revestimentoExterno.nome}"/>
                    </fieldset>

                    <fieldset class="grid_11">
                        <legend>Abastecimento de água</legend>

                        <p:inputText readonly="true" styleClass="grid_23" value="#{managerEditarCadastroDomiciliar.cadastro.abastecimentoAgua.nome}"/>
                    </fieldset>

                    <fieldset class="grid_11 omega">
                        <legend>Tratamento de água no domicílio</legend>

                        <p:inputText readonly="true" styleClass="grid_23" value="#{managerEditarCadastroDomiciliar.cadastro.tratamentoAgua.nome}"/>
                    </fieldset>
                    <div class="clear-both"/>

                    <fieldset class="grid_11">
                        <legend>Forma de escoamento do banheiro ou sanitário</legend>

                        <p:inputText readonly="true" styleClass="grid_23" value="#{managerEditarCadastroDomiciliar.cadastro.escoamentoSanitario.nome}"/>
                    </fieldset>

                    <fieldset class="grid_11 omega">
                        <legend>Destino do lixo</legend>

                        <p:inputText readonly="true" styleClass="grid_23" value="#{managerEditarCadastroDomiciliar.cadastro.destinoLixo.nome}"/>
                    </fieldset>

                </p:panel>

                <p:panel id="animaisPanel" styleClass="container_24 clearfix withoutBorder">
                    <h5 class="title">Animais no domicílio</h5>

                    <p:outputLabel value="#{managerEditarCadastroDomiciliar.cadastro.possuiAnimalDomicilio ? 'Sim' : 'Não'}" styleClass="grid_3"/>

                    <p:outputLabel value="Quantos?" styleClass="grid_7" for="quantosAnimais"
                                   rendered="#{managerEditarCadastroDomiciliar.cadastro.possuiAnimalDomicilio}"/>
                    <p:inputText id="quantosAnimais" styleClass="grid_10" readonly="true"
                                 rendered="#{managerEditarCadastroDomiciliar.cadastro.possuiAnimalDomicilio}"
                                 value="#{managerEditarCadastroDomiciliar.cadastro.quantidadeAnimalDomicilio}"/>
                    <div class="clear-both"/>

                    <fieldset class="grid_23" 
                              style="#{managerEditarCadastroDomiciliar.cadastro.possuiAnimalDomicilio ? '' : 'display: none'}">
                        <legend>Quais?</legend>

                        <ui:repeat value="#{managerEditarCadastroDomiciliar.cadastro.animalDomicilio}" var="animal">
                            <p:inputText value="#{animal.nome}" styleClass="grid_4" readonly="true"/>
                        </ui:repeat>
                    </fieldset>
                    <div class="clear-both"/><br/>

                </p:panel>

                <p:panel id="familiasPanel" styleClass="container_24 clearfix withoutBorder" style="margin-bottom: 0; padding-bottom: 0">
                    <h5 class="title">Famílias</h5>


                    <p:dataTable id="familiasTable" var="item" 
                                 value="#{managerEditarCadastroDomiciliar.cadastro.cadastroDomiciliarFamilias}" 
                                 styleClass="grid_24" emptyMessage="Nenhum registro" rowIndexVar="idfamilia">  
                        <f:facet name="header">
                            Famílias
                        </f:facet>

                        <p:column headerText="Nome" style="vertical-align: middle; text-align: center">
                            <h:outputText value="#{item.responsavel.nome.toString().concat(' - ').concat(item.responsavel.numeroCartaoSus)}"/>
                        </p:column>

                        <p:column headerText="Renda familiar" style="vertical-align: middle; text-align: center">
                            <h:outputText value="#{item.rendaFamiliar.nome}"/>
                        </p:column>

                        <p:column headerText="Reside desde" style="vertical-align: middle; text-align: center">
                            <h:outputText value="#{item.resideDesde}">
                                <f:convertDateTime pattern="MM/yyyy"/>
                            </h:outputText>
                        </p:column>
                    </p:dataTable>
                </p:panel>

                <div class="clear"/><br/>

                <div class="buttonAction">
                    <p:button href="pesquisarcadastrodomiciliar.xhtml" value="Voltar" icon="ui-icon-arrowreturnthick-1-w" />
                </div>

            </h:form>

            <link rel="stylesheet" type="text/css" href="media/css/cadastroIndividual.css"/>

        </ui:define>
    </ui:composition>

</html>
